require('./index.less');
import $ from 'jquery';
import jqPaginator from '../lib/jqPaginator.min';
$(function() {
    $("#saller").html("售票员:售票员01")
    var sale_report_json = { "id": "1.0", "jsonrpc": "2.0", "method": "getSaleSettleReportList", "params": { "sellerId": 1, "page": { "pageNum": 1, "size": 10 } } };
    var salereportdata = $.ajax({
        contentType: "application/json;charset=utf-8",
        url: "/api/reportApi",
        data: JSON.stringify(sale_report_json),
        type: "post",
        dataType: "json"
    });
    salereportdata.then(function(data) {
        for (var i = 0; i < data.result.body.list.length; i++) {
            var srporthtml = $("#sale-report").html();
            var srdata = data.result.body.list[i];
            var conReg = /(?:\{)(\w*)(?:\})/g;
            var source = srporthtml.replace(conReg, function(node, key) {
                return srdata[key];
            });
            $(".sale-report").append(source);
        }
        $("#page1").jqPaginator({
            totalPages: 15,
            visiblePages: 1,
            currentPage: 1,
            first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
            prev: '<li class="prev"><a href="javascript:void(0);"><i class="arrow arrow2"><\/i>上一页<\/a><\/li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页<i class="arrow arrow3"><\/i><\/a><\/li>',
            last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
            onPageChange: function(n) {
                $(".sale-report").empty();
                salereportdata.then(function(data) {
                    for (var i = 0; i < data.result.body.list.length; i++) {
                        var srporthtml = $("#sale-report").html();
                        var srdata = data.result.body.list[i];
                        var conReg = /(?:\{)(\w*)(?:\})/g;
                        var source = srporthtml.replace(conReg, function(node, key) {
                            return srdata[key];
                        });
                        $(".sale-report").append(source);
                    }
                })
            }
        });
    })

})